var Channel = (function ($) {
    return {
        initIndex: function () {
            Channel.initDateRangePicker();
        },
        initDateRangePicker: function () {
            dateRangePicker = $('#fromdate, #todate').daterangepicker({
                buttonImage: '/content/images/calendar.gif',
                dateFormat: 'yy-mm-dd',
                datepickerOptions: {
                    showOtherMonths: true,
                    changeMonth: true,
                    changeYear: true,
                    selectOtherMonths: true,
                    closeText: 'OK'
                }
            });
        },
        initDatePicker: function () {
            dateRangePicker = $('#open_date').datepicker({
                showOn: "both", 
                buttonImage: '/content/images/calendar.gif',
                dateFormat: 'yy-mm-dd'
            });
        },

        initEdit: function () {
            Channel.initDatePicker();
            $("select[name=channel_id]").change(function () {
                location.href = 'index.php/admin/channel/edit?channel_id=' + $("select[name=channel_id]").val() + '&open_date=' + $("#open_date").val();
            });
        }
    };
})(jQuery);
